package divinity.utils.log
{
	/*
	*	this has to be updated
	*/
	//import flash.globalization.DateTimeFormatter;
	//import flash.globalization.DateTimeStyle;
	//import flash.globalization.LocaleID;
	
	public class Log
	{
		private static var _inputs:Array=[];
		private var _name:String;
		//private static var df:DateTimeFormatter = new DateTimeFormatter(LocaleID.DEFAULT, DateTimeStyle.NONE, DateTimeStyle.LONG);
		public function Log(logname:String="")
		{
			_name=logname;
		}
		public function addLog(clip:Object,txt:String):void
		{
			var _input:Object={};
			_input.time=new Date();
			_input.name=clip;
			_input.entry=txt;
			_input.owner=_name;
			_inputs.push(_input)			
		}
		public function getLog(sch:String=null):String
		{
			var value:String="\n----------\n"+_name+"\n----------\n";
			var time:String;
			var search:String=sch;
			var str:String;
			
			if(sch==null)
			{
				search=_name;				
			}
			else
			{
				value+=" Displaying for '"+search+"'\n";
			}
			search=search.toLowerCase();			
			for(var n:int=0;n<_inputs.length;n++)
			{			
				str="";
				for each(var prop:String in _inputs[n])
				{					
					str+=String(prop).toLowerCase();
				}				
				if(str.indexOf(search)!=-1)
				{
					value+=formatLog(_inputs[n]);
				}
			}
			return value;
		}
		public static function get list():String
		{
			var value:String="\n-----------------\nALL LOG ENTRIES\n-----------------\n";
			var time:String;
			for(var n:int=0;n<_inputs.length;n++)
			{
				value+=formatLog(_inputs[n]);
			}
			return value;
		}
		private static function formatLog(info:Object):String
		{
			var ret:String;
			var time:String="need to reprogram";
			ret="  [ "+time+" ] "+info.name+" | "+info.owner+"			"+info.entry+"\n";
			return ret;
		}
	}
}